
if exists (select name from sysobjects where name like 'sp_UpdateMatKhau')
	drop procedure sp_UpdateMatKhau
go
create proc sp_UpdateMatKhau(@madangnhap int, @matkhau char)
as
begin
	Update TaiKhoanDangNhapNV set MatKhau=@matkhau where MaDangNhap=@madangnhap
end
go

------------------------
if exists (select name from sysobjects where name like 'sp_TaoTKDangNhap')
	drop procedure sp_TaoTKDangNhap
go
create proc sp_TaoTKDangNhap(@tendangnhap int, @matkhau char)
as
begin
	insert into TaiKhoanDangNhapNV values(@tendangnhap, @matkhau, getdate(),0)
end
go
-------------------------
if exists (select name from sysobjects where name like 'sp_TaoNhanVien')
	drop procedure sp_TaoNhanVien
go
create proc sp_TaoNhanVien
(@matruso int,@ten nvarchar(50),@TenDN varchar,@matkhau varchar,@ngaysinh datetime,@diachi nvarchar(50),@dienthoai int,@maGTinh int,@cmnd int,@mota nvarchar(50))
as
begin
declare @maDN int
	insert into TaiKhoanDangNhapNV values(@TenDN, @matkhau, getdate(),0)
	set @maDN
	insert into NhanVien values(@matruso, @ten, @maDN, @ngaysinh, @diachi, @dienthoai, @maGTinh, @cmnd, @mota,0 )
end
go
-----------------
if exists (select name from sysobjects where name like 'sp_GioiTinh')
	drop procedure sp_GioiTinh
go
create proc sp_GioiTinh
as
begin
	select * from GioiTinh
end
go
-----------------------------
if exists (select name from sysobjects where name like 'sp_GioiTinh_ByID')
	drop procedure sp_GioiTinh_ByID
go
create proc sp_GioiTinh_ByID (@ma int)
as
begin
	select * from GioiTinh where MaLoaiGioiTinh=@ma
end
go

------------------------
if exists (select name from sysobjects where name like 'sp_DanhSachNhanVien')
	drop procedure sp_DanhSachNhanVien
go
create proc sp_DanhSachNhanVien
as
begin
	select * from NhanVien
end
go
---------------------
if exists (select name from sysobjects where name like 'sp_DanhSachNhanVien_ByID')
	drop procedure sp_DanhSachNhanVien_ByID
go
create proc sp_DanhSachNhanVien_ByID (@maNV int)
as
begin
	select * from NhanVien where MaNV=@maNV
end
go

----------------

if exists (select name from sysobjects where name like 'sp_ChucVuActive_View')
	drop procedure sp_ChucVuActive_All
go
create proc sp_ChucVuActive_All
as
begin
	select * from ChucVu where DelFlag=0
end
go
---------
if exists (select name from sysobjects where name like 'sp_QuyenActive_View')
	drop procedure sp_QuyenActive_View
go
create proc sp_QuyenActive_View
as
begin
	select * from Quyen where DelFlag=0
end
go
